import axios from 'axios';
// axios提供的拦截器interceptor
// 拦截请求
axios.interceptors.request.use( config => {
    config.headers['Authorization'] = 'Bearer '+ localStorage.getItem("token");
    return config;
});
// 拦截响应
axios.interceptors.response.use(response => {
    console.log("response:",response);
    if(response.data.code == 2001){
        location.href = "/login";
    }
    return response;
})

export {axios};
export const url = "/api";